//
//  LJHTextTableCell.m
//  HEARME
//
//  Created by mac on 16/2/29.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "LJHTextTableCell.h"

@implementation LJHTextTableCell

- (void)dealloc
{
    [_contentCount release];
    [_newsDigest release];
    [_newsPic release];
    [_newsTitle release];
    [_nextBtn release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createCell];
    }
    
    return self;
}

-(void)createCell
{
    self.newsPic = [[UIImageView alloc] initWithFrame:CGRectMake(self.contentView.bounds.origin.x + WIDTH*0.03, self.contentView.bounds.origin.y + WIDTH*0.03, WIDTH*0.24 , WIDTH*0.24) ];
    self.newsPic.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.newsPic];
    [_newsPic release];
    
    self.newsTitle = [[LJHBaseLable alloc] initWithFrame:CGRectMake(self.newsPic.frame.origin.x + self.newsPic.frame.size.width + 10, self.contentView.bounds.origin.y + 15, 200*WIDTH/375, 20*HEIGHT/667)];
    self.newsTitle.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.newsTitle];
    [_newsTitle release];
    
    self.newsDigest = [[LJHBaseLable alloc] initWithFrame:CGRectMake(self.newsPic.frame.origin.x + self.newsPic.frame.size.width + 10 ,self.newsTitle.frame.origin.y + self.newsTitle.frame.size.height + 10, 200*WIDTH/375, 20*HEIGHT/667)];
    self.newsDigest.backgroundColor = [UIColor clearColor];
    self.newsDigest.font = [UIFont systemFontOfSize:13 weight:0];
    [self.contentView addSubview:self.newsDigest];
//    self.newsDigest.textColor = [UIColor lightGrayColor];
    self.newsDigest.numberOfLines = 2;
    [_newsDigest release];
    
    UIImageView *iconImage = [[UIImageView alloc] initWithFrame:CGRectMake(self.newsPic.frame.origin.x + self.newsPic.frame.size.width + 10, self.newsDigest.frame.origin.y + self.newsDigest.frame.size.height + 10, 20*WIDTH/375, 20*HEIGHT/667)];
    iconImage.backgroundColor = [UIColor clearColor];
    iconImage.image = [UIImage imageNamed:@"find_specialicon@2x.png"];
    [self.contentView addSubview:iconImage];
    [iconImage release];
    
    self.contentCount = [[LJHBaseLable alloc] initWithFrame:CGRectMake(self.newsPic.frame.origin.x + self.newsPic.frame.size.width + 15 , self.newsDigest.frame.origin.y + self.newsDigest.frame.size.height + 10, 70*(WIDTH/375), 20*(HEIGHT/667))];
    self.contentCount.backgroundColor = [UIColor clearColor];
    self.contentCount.font = [UIFont systemFontOfSize:13 weight:0];
    [self.contentView addSubview:self.contentCount];
    self.contentCount.textAlignment = NSTextAlignmentRight;
//    self.contentCount.textColor = [UIColor lightGrayColor];
    [_contentCount release];
    
    self.nextBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.nextBtn.frame = CGRectMake(WIDTH-40, self.newsPic.frame.origin.y + self.newsPic.frame.size.height/2-15, 30*(WIDTH/375), 30*(HEIGHT/667));
    self.nextBtn.backgroundColor = [UIColor clearColor];
    [self.nextBtn setImage:[UIImage imageNamed:@"cell_arrow@2x.png"] forState:UIControlStateNormal];
    [self.contentView addSubview:self.nextBtn];
    
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(self.newsPic.frame.origin.x + self.newsPic.frame.size.width + 10, self.newsPic.frame.origin.y + self.newsPic.frame.size.height + 9, WIDTH - self.newsPic.frame.origin.x + self.newsPic.frame.size.width + 10, 0.5)];
    lineView.backgroundColor = [UIColor lightGrayColor];
    [self.contentView addSubview:lineView];
}

-(void)setTextModel:(LJHChildListModel *)textModel
{
    if (_textModel != textModel) {
        [_textModel release];
        _textModel = [textModel retain];
    }
    NSURL *url = [NSURL URLWithString:textModel.coverPath];
    [self.newsPic sd_setImageWithURL:url placeholderImage:PLACEHOLDER];
    self.newsTitle.text = textModel.title;
    self.newsDigest.text = textModel.subtitle;
    self.contentCount.text = textModel.footnote;
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
